home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / sharewar / webscrip / webscripter4s.exe / {app} / Includes / jsClock.ob < prev    next >
Encoding:
Text File  |  2001-07-11  |  2.0 KB  |  75 lines

  1. //begin_lib <!-- Begin External JavaScript -- DO NOT REMOVE THIS LINE -->
  2.  
  3. var el; var clTimer = null; var time;
  4. var clDay=new Array(" Sunday"," Monday"," Tuesday"," Wednesday"," Thursday"," Friday"," Saturday");
  5. var clMonth=new Array(" January "," Febuary "," March "," April "," May "," June "," July "," August "," September "," October "," November "," December ");
  6.  
  7. function jsClock(){
  8. this.SetElement = cl_SetElement;
  9. this.GetShortTime = cl_GetShortTime;
  10. this.GetShortTimeDate = cl_GetShortTimeDate;
  11. this.GetLongTimeDate = cl_GetLongTimeDate;
  12. this.StopNow = cl_StopNow;
  13. }
  14.  
  15. function get_Hours(){
  16. return ((time.getHours() >12) ? time.getHours() -12 : time.getHours());;
  17. }
  18.  
  19. function get_Minutes(){
  20. return ((time.getMinutes() < 10) ? ":0" : ":") +time.getMinutes();
  21. }
  22.  
  23. function get_Seconds(){
  24. var retValue = ((time.getSeconds() < 10) ? ":0" : ":") +time.getSeconds();
  25. retValue+= ((time.getHours() >=12) ? " P.M." : " A.M.");
  26. return retValue;
  27. }
  28.  
  29. function get_WeekDay(){
  30. return clDay[time.getDay()];
  31. }
  32.  
  33. function get_Month(){
  34. return clMonth[time.getMonth()];
  35. }
  36.  
  37. function setValue(val){
  38.     if(el){
  39.     el.value =val;
  40.     }else{
  41.     window.status = val;
  42.     }
  43. }
  44.  
  45. function cl_SetElement(element){
  46. el = element;
  47. }
  48.  
  49. function cl_GetShortTime(){
  50. time = new Date();
  51. var retValue = get_Hours()+get_Minutes()+get_Seconds();
  52. setValue(retValue);
  53. clTimer = setTimeout("cl_GetShortTime()",1000);
  54. }
  55.  
  56. function cl_GetShortTimeDate(){
  57. time = new Date();
  58. var retValue = get_Hours()+get_Minutes()+get_Seconds()+" "+(time.getMonth()+1)+"/"+time.getDate()+"/"+time.getFullYear();
  59. setValue(retValue);
  60. clTimer = setTimeout("cl_GetShortTimeDate()",1000);
  61. }
  62.  
  63. function cl_GetLongTimeDate(){
  64. time = new Date();
  65. var retValue = get_Hours()+get_Minutes()+get_Seconds()+" "+get_WeekDay()+", "+get_Month()+" "+time.getDate()+", "+time.getFullYear();
  66. setValue(retValue);
  67. clTimer = setTimeout("cl_GetLongTimeDate()",1000);
  68. }
  69.  
  70. function cl_StopNow(){
  71. clearTimeout(clTimer);
  72. }
  73.  
  74. //end_lib <!-- End External JavaScript -- DO NOT REMOVE THIS LINE -->
  75.